import Cookies from 'js-cookie'

const TOKEN_KEY = 'access_token'
const REGRESH_TOKEN_KEY = 'refresh_token'

export const getToken = () => Cookies.get(TOKEN_KEY)

export const setToken = (token, params = {}) => {
  Cookies.set(TOKEN_KEY, token, params)
}

export const setRefreshToken = (token) => {
  Cookies.set(REGRESH_TOKEN_KEY, token)
}

export const redirectTo = url => {
    uni.redirectTo({
      url: url
    });
  }; 

  export const showToast = (msg, toastType, timeout) => {
    wx.hideLoading();
    wx.showToast({
      title: msg,
      icon: toastType || 'none',
      duration: timeout || 3000,
      mask: true
    });
  };